﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using Wicresoft.SelfService.DAO;

namespace Wicresoft.SelfService.BL
{
    public class Common
    {
        public static IList<actionType> getActions(roleType role, serviceStatus status, serviceStep step)
        {
            IList<actionType> action = null;

            #region //审批人自己提交单子后，不可以自己进行审批-No：
            //switch (role)
            //{
            //    case roleType.owner:
            //        switch (status)
            //        {
            //            case serviceStatus.Draft:
            //                action = new List<actionType>();
            //                action.Add(actionType.save);
            //                action.Add(actionType.cancel);
            //                action.Add(actionType.submit);
            //                action.Add(actionType.uploadFile);
            //                break;
            //            case serviceStatus.Pending:
            //                switch (step)
            //                {
            //                    case serviceStep.local_interface:
            //                        action = new List<actionType>();
            //                        action.Add(actionType.undo);
            //                        action.Add(actionType.uploadFile);
            //                        action.Add(actionType.checkSuggestion);
            //                        break;
            //                    default:
            //                        action = new List<actionType>();
            //                        action.Add(actionType.checkSuggestion);
            //                        break;
            //                }
            //                break;
            //            default:
            //                action = new List<actionType>();
            //                action.Add(actionType.checkSuggestion);
            //                break;
            //        }
            //        break;
            //    case roleType.approver:
            //        switch (status)
            //        {
            //            case serviceStatus.Pending:
            //                action = new List<actionType>();
            //                action.Add(actionType.approve);
            //                action.Add(actionType.reject);
            //                action.Add(actionType.uploadFile);
            //                action.Add(actionType.addSuggestion);
            //                break;
            //            default:
            //                action = new List<actionType>();
            //                action.Add(actionType.checkSuggestion);
            //                break;
            //        }
            //        break;
            //    case roleType.others:
            //        action = new List<actionType>();
            //        action.Add(actionType.checkSuggestion);
            //        break;
            //}
            #endregion

            #region //审批人自己提交单子后，可以自己进行审批-Yes：
            if (roleType.ownerandapprover == role)
            {
                switch (status)
                {
                    case serviceStatus.Draft:
                        action = new List<actionType>();
                        action.Add(actionType.save);
                        action.Add(actionType.cancel);
                        action.Add(actionType.submit);
                        action.Add(actionType.uploadFile);
                        break;
                    case serviceStatus.Pending:
                        switch (step)
                        {
                            case serviceStep.local_interface:
                                action = new List<actionType>();
                                action.Add(actionType.approve);
                                action.Add(actionType.reject);
                                action.Add(actionType.undo);
                                action.Add(actionType.uploadFile);
                                action.Add(actionType.checkSuggestion);
                                break;
                            default:
                                action = new List<actionType>();
                                action.Add(actionType.checkSuggestion);
                                break;
                        }
                        break;
                    default:
                        action = new List<actionType>();
                        action.Add(actionType.checkSuggestion);
                        break;
                }
            }
            else if (roleType.owner == role) 
            {
                switch (status)
                {
                    case serviceStatus.Draft:
                        action = new List<actionType>();
                        action.Add(actionType.save);
                        action.Add(actionType.cancel);
                        action.Add(actionType.submit);
                        action.Add(actionType.uploadFile);
                        break;
                    case serviceStatus.Pending:
                        switch (step)
                        {
                            case serviceStep.local_interface:
                                action = new List<actionType>();
                                action.Add(actionType.undo);
                                action.Add(actionType.uploadFile);
                                action.Add(actionType.checkSuggestion);
                                break;
                            default:
                                action = new List<actionType>();
                                action.Add(actionType.checkSuggestion);
                                break;
                        }
                        break;
                    default:
                        action = new List<actionType>();
                        action.Add(actionType.checkSuggestion);
                        break;
                }
            }
            else if (roleType.approver == role) 
            {
                switch (status)
                {
                    case serviceStatus.Pending:
                        action = new List<actionType>();
                        action.Add(actionType.approve);
                        action.Add(actionType.reject);
                        action.Add(actionType.uploadFile);
                        action.Add(actionType.addSuggestion);
                        break;
                    default:
                        action = new List<actionType>();
                        action.Add(actionType.checkSuggestion);
                        break;
                }
            }
            else if(roleType.others==role)
            {
                action = new List<actionType>();
                action.Add(actionType.checkSuggestion);
            }

            #endregion

            return action;
        }
    }
}
